<template>
	<view class="bindZFBWrapper wrapperLayer colCen wd100 borderBox">
		<view class="pageContainer wd100 pd20 borderBox" v-if="isAudit == false">
			<view class="modeText wd100 rowCen">
				支付宝账号信息
			</view>
			<view class="formContent colCen wd100 borderBox pd30">
				<view class="formItem rowCenBet wd100">
					<view class="itemLabel">
						真实姓名
					</view>
					<input class="formInput" placeholder-class="placeInput" type="text" v-model="name"
						placeholder="输入支付宝实名认证的姓名" />
				</view>
				<view class="formItem rowCenBet wd100">
					<view class="itemLabel">
						支付宝账号
					</view>
					<input class="formInput" placeholder-class="placeInput" type="text" v-model="account"
						placeholder="输入支付宝账号(手机号/邮箱)" />
				</view>
			</view>

			<view class="fixedContent rowCen pd20 borderBox wd100">
				<view class="subBtn rowCenCen wd100" @click="submit()">
					<text>绑定</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import common from '@/utils/util.js'
	import * as UserApi from '@/api/user'
	import storage from '../../utils/storage';
	export default {
		data() {
			return {
				isAudit:true,
				name: "",
				account: "",
			}
		},
		onLoad() {
			let config = storage.get('baseInfo');
			if(config.withdraw.isAudit != 1){
				this.isAudit = false;
			}
			this.getUserInfo();
		},
		methods: {
			getUserInfo() {
				UserApi.getUserInfo().then((res) => {
					if(res.code == 1){
						let userInfo = res.data
						this.name = userInfo.real_name
						this.account = userInfo.alipay_account
					}
				}).catch((e) => {
					return this.$toast('接口请求错误');
				})
			},
			
			submit() {
				if (!this.name || !this.account) {
					uni.showToast({
						title: '真实姓名和支付宝账号信息不能为空~',
						icon: 'none'
					})
					return
				}
				UserApi.bindZfb({real_name:this.name,alipay_account:this.account}).then((res) => {
					if(res.code == 1){
						this.$toast('绑定成功');
						setTimeout(()=>{
							uni.navigateBack({
								delta: 1
							})
						},800)
						
					}else{
						return this.$toast(res.msg);
					}
				}).catch((e) => {
					return this.$toast('接口请求错误');
				})
			},
		}
	}
</script>

<style lang="scss">
	.bindZFBWrapper {
		.pageContainer {
			.modeText {
				font-size: 24rpx;
				font-weight: 500;
				color: #333333;
				height: 70rpx;
			}

			.formContent {
				margin-top: 20rpx;
				background: #FFFFFF;
				border-radius: 20rpx;

				.formItem {
					height: 100rpx;
					font-size: 30rpx;
					font-weight: 500;
					color: #333333;

					.itemLabel {
						width: 176rpx;
					}

					.formInput {
						flex: 1;
						font-size: 30rpx;
						color: #333333
					}

					.placeInput {
						font-size: 28rpx;
						font-weight: 400;
						color: #999999
					}
				}

				.verCodeBtn {
					white-space: nowrap;
					height: 54rpx;
					background: #FFFFFF;
					border: 1rpx solid #FFBA03;
					border-radius: 27rpx;
					font-size: 24rpx;
					font-weight: 500;
					color: #FFBA03;
					padding: 0 20rpx;
					margin-left: 20rpx;
				}
			}

			.fixedContent {
				position: fixed;
				left: 0;
				bottom: calc(var(--window-bottom) + 80rpx);

				.subBtn {
					height: 90rpx;
					background: #09C15F;
					border-radius: 50rpx;
					font-size: 34rpx;
					font-weight: 500;
					color: #FFFFFF;
				}
			}
		}
	}
</style>